package leetcode;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2022/1/18 8:40
 */
public class Test119 {

    @Test
    public void test(){
        System.out.println(getRow(3));
    }


    public List<Integer> getRow(int rowIndex) {
        List<Integer> list = new ArrayList<>();
        int[][] arr = new int[rowIndex+1][rowIndex+1];
        for (int i = 0; i < arr.length; i++) {
            arr[i][0] = 1;
            arr[i][i] = 1;
            if(i>1) {
                for (int j = 1; j < arr[i].length-1; j++) {
                    arr[i][j] = arr[i-1][j-1]+arr[i-1][j];
                }
            }
        }
        for (int i : arr[rowIndex]) {
            list.add(i);
        }

        return list;
    }
}
